package dyyx.stream;

import org.apache.flink.api.java.functions.KeySelector;
import org.apache.flink.api.java.tuple.Tuple5;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class SimpleEventStream {

	public static void main(String[] args) throws Exception {
		
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
		 
	    System.out.println(env);	
	    System.out.println("parallelism="+env.getParallelism());	

	    env.setParallelism(1);	    
	    System.out.println("parallelism2="+env.getParallelism());
	    
	    /*
	    String file = "file:/Users/dugang/work/demos/flinkdemo/docs/data/events.txt";
	    DataStream<Tuple5<String,String,String,String, Double>> events = env.readCsvFile(file)
               .types(String.class,String.class,String.class,String.class, Double.class);
		
		*/
	    
	    
        DataStream<String> text = env.fromElements(
            "hello","cat","dog","cat","hello","cat","dog","dog","cat"
        );
                
        text.keyBy(new MyKeySelector())
        .print();
        
     
        env.execute();

	}
	
	private static class MyKeySelector  implements KeySelector<String,String>{
		public String getKey(String value) {
			return value;
		}
	}
	
	

}
